<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="__ROOT__/Public/Admin/css/shortcut icon" href="favicon.ico">
    <link href="__ROOT__/Public/Admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/js/plugins/cityPicker/city-picker.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__ROOT__/Public/Admin/css/edit.css" rel="stylesheet"/>

<style>

</style>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       
        <div class="row">
            <form class="form-horizontal m-t js-ajax-forms" id="signupForm" action="<if condition="$editdata">{:U('Admin/GeneralApply/update')}<else />{:U('Admin/GeneralApply/add')}</if>" method="post" enctype="multipart/form-data">
            <input type="hidden" name="ID" value="{$editdata['ID']}">
            <div class="col-sm-8  col-md-offset-2">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">任务 * </label>
                                <div class="col-sm-8">
                                    <input id="TIDName"  class="form-control selector-icon"  name="TIDName" aria-required="true" aria-invalid="true" class="error" value='{$editdata.TIDName}'>
                                    <input id="TID"  type='hidden'  name="TID" aria-required="true" aria-invalid="true" class="error" value='{$editdata.TID}'>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">申请部门 * </label>
                                <div class="col-sm-8">
                                    <input id="DepName"  class="form-control selector-icon"  name="DepName" aria-required="true" aria-invalid="true" onclick="openselector('DepID','DepName')" data-toggle="modal" data-target="#myModal" type="text" class="error" value='{$editdata.DepName}'>
                                    <input id="DepID"  type='hidden'  name="DepID" aria-required="true" aria-invalid="true" class="error"   value='{$editdata.DepID}'>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">申请人用户 * </label>
                                <div class="col-sm-8">
                                 <input id="UserName"  class="form-control selector-icon"  onclick="openselector('UserID','UserName')" data-toggle="modal" data-target="#myModal" type="text"  name="UserName" aria-required="true" aria-invalid="true" class="error" value='{$editdata.UserName}'>
                                <input id="UserID"  type='hidden'  name="UserID" aria-required="true" aria-invalid="true" class="error" value='{$editdata.UserID}'>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label">申请标题 *</label>
                                <div class="col-sm-8">
                                    <input id="Title"  class="form-control"  name="Title" aria-required="true" aria-invalid="true" class="error" value='{$editdata.Title}'>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-3 control-label"> 申请内容 * </label>
                                <div class="col-sm-8">
                                    <textarea id="Content" name="Content"  class="form-control"   value="{$editdata.Content}"> {$editdata.Content}</textarea> 
                                </div>
                            </div>

                            <div class="form-group has-success">
                                <label class="col-sm-3 control-label" style="color:#686b6d">申请时间 * </label>
                                <div class="col-sm-8">
                                    <input style="border-color:#cfdadd" type="text" id="ApplyTime"  name="ApplyTime" class="form-control date laydate-icon" value="{$editdata.ApplyTime}">
                                </div>
                            </div>

                                    <!-- 做输入匹配 -->
                            <div class="form-group">
                                <label class="col-sm-3 control-label"> 抄送人  </label>
                                <div class="col-sm-8">
                                    <input id="CopyUserName"  onclick="openselector('CopyUser','CopyUserName')" data-toggle="modal" data-target="#myModal" type="text"   class="form-control selector-icon"  name="CopyUserName" aria-required="true" aria-invalid="true" class="error" value='{$editdata.CopyUserName}'>
                                    <input id="CopyUser"  type='hidden'  name="CopyUser" aria-required="true" aria-invalid="true" class="error" value='{$editdata.CopyUser}'>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label"> 打印人 </label>
                                <div class="col-sm-8">
                                    <input id="PrintUserName"  onclick="openselector('PrintUserID','PrintUserName')" data-toggle="modal" data-target="#myModal" type="text"  class="form-control selector-icon"  name="PrintUserName" aria-required="true" aria-invalid="true" class="error" value='{$editdata.PrintUserName}'>
                                    <input id="PrintUserID"  type='hidden'  name="PrintUserID" aria-required="true" aria-invalid="true" class="error" value='{$editdata.PrintUserID}'>
                                </div>
                            </div>

                            <div class="form-group">
                                <hr/>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <a class="btn btn-white" href="javascript:void(0);" onclick="self.location=document.referrer;">返回</a>
                                    &nbsp&nbsp&nbsp
                                    <button class="btn btn-primary keep" type="submit">保存</button>
                                </div>
                            </div>
                        
                    </div>
                </div>
            </div>
           
            </form>
        </div>
    </div>
    <script src="__ROOT__/Public/Admin/js/jquery.min.js"></script>
    <script src="__ROOT__/Public/Admin/js/bootstrap.min.js"></script>
    <script src="__ROOT__/Public/Admin/js/plugins/layer/laydate/laydate.js"></script>
    <script src="__ROOT__/Public/Admin/js/plugins/layer/layer.min.js"></script>
    <script src="__ROOT__/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="__ROOT__/Public/Admin/js/ajaxForm.js"></script>
    <script src="__ROOT__/Public/Admin/js/plugins/sweetalert/sweetalert.min.js"></script>
    <link href="__ROOT__/Public/Admin/css/selector/selectorstyle.css" rel="stylesheet"/>
    <script src="__ROOT__/Public/Admin/js/plugins/selector/selector.js"></script>
    <script src="__ROOT__/Public/Admin/js/plugins/selector/jquery.ztree.all.js"></script>
   <!--  <script src="__ROOT__/Public/Admin/js/Contract/save.js"></script> -->
    <script type="text/javascript">
    var icon = "<i class='fa fa-times-circle'></i>";
    var form = $('form.js-ajax-forms');
    var formloading = false;
    var FPWriteDate = {
            elem: '#ApplyTime',
            format: 'YYYY-MM-DD',
            min: '2009-06-16 23:59:59',
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
               
            }
        };
    laydate(FPWriteDate);
     $('#TIDName').on('click', function(){
        layer.open({
            title:'选择任务',
            type: 2,
            area: ['1200px', '500px'],
            fixed: false, //不固定
            maxmin: true,
            content: "/index.php?m=Admin&c=GeneralApply&a=tasklist"
        });
    });

        $(document).ready(function () {

                form.validate({
                //验证规则
                rules: {
                    TIDName: {
                        required: true
                    },
                    DepName:{
                        required: true
                    },
                    UserName: {
                        required: true
                    },
                    Title: {
                        required: true
                    },
                    Content: {
                        required: true
                    },
                    ApplyTime: {
                        required: true
                    }
                },
                //验证未通过提示消息
                messages: {
                    TIDName:{
                        required: icon + "请选择任务"
                    },
                    DepName :{
                        required: icon + "请选择部门"
                    },
                    UserName:{
                        required: icon + "请选择申请用户"
                    },
                    Title:{
                        required: icon + "请输入标题"
                    },
                    Content:{
                        required: icon + "请输入内容"
                    },
                    ApplyTime:{
                        required: icon + "请选择申请时间"
                    }
                },
                //验证通过，提交表单
                submitHandler : function(forms) {
                    if (formloading)
                    return;
                    $(forms).ajaxSubmit({
                        url : form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
                        dataType : 'json',
                        beforeSubmit : function(arr, $form, options) {
                            formloading = true;
                        },
                        success : function(data, statusText, xhr, $form) {
                            formloading = false;
                            if (data.status) {
                                //添加成功
                                swal({
                                    title: "继续操作？",
                                    text: "操作成功！",
                                    type: "success",
                                    showCancelButton: true,
                                    confirmButtonColor: "#DD6B55",
                                    confirmButtonText: "确认",
                                    cancelButtonText: "返回",
                                    closeOnConfirm: false,
                                    closeOnCancel: false
                                },
                                function (isConfirm) {
                                    if (isConfirm) {
                                        document.location.reload();
                                        //document.location.href = "/index.php?m=Admin&c=Contract&a=ContractBody&ContractID="+data.info.ID+"&ContractType="+data.info.ContractType;
                                    } else {
                                       // document.location.href = "{:U('Admin/Contract/ContractBody')}";
                                        return true;
                                    }
                                }); 
                            } else {
                                swal("操作失败", data.info, "error");
                            }
                        }
                    });
                }
            });


        })
           





    </script>
</body>

</html>
